<?php
Yii::app()->clientScript->registerScriptFile((Yii::app()->baseUrl) . '/vendor/ckeditor/ckeditor.js', CClientScript::POS_HEAD);
?>
<link href="<?php echo CSS_User_URL; ?> /Article_Post_style.css" rel="stylesheet" type="text/css">        
<script src="<?php echo JS_User_URL; ?>/Article_Post_js.js" type="text/javascript"></script>

<section id="main_cover" class="cover center-child">
    <div class="cover_intro">
        <div id="someone_image" class="center-child image_parent">
            <a href="#">
                <img src="<?php echo Yii::app()->baseUrl; ?>/images/People_demo.jpg" alt="Ideawebsite.com">
            </a>
        </div>
        <div id="someone_things">
            <h1 class="someone_slogan">Always do the best</h1>
            <span class="someone_owner"><a href="#">Adam Kenisa</a></span>

        </div>

    </div>
</section>


<div class="home_wrapper">

    <div><h3 class="page_title">Đăng bài viết ý tưởng </h3></div>
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'post-idea-form',
        'enableAjaxValidation' => true,
        'htmlOptions' => array('enctype' => 'multipart/form-data'),
        'clientOptions' => array(
            'validateOnSubmit' => true,
        ),
    ));
    ?>
    <div class="article_setting">
        <div class="setting_column1">
            <div class="setting_field">
                <span class="field_title">Tiêu đề: </span>               
                <?php echo $form->textField($YTuong, 'TieuDe', array('class' => 'field_value')); ?>
                <span class="field_status"><?php echo $form->error($YTuong, 'TieuDe'); ?></span>
            </div>
            <div class="setting_field">
                <span class="field_title">Giới thiệu: </span>
<!--                <textarea class="field_value" placeholder="Giới thiệu sơ việc về ý tưởng"></textarea>
                <span class="field_status">Hợp lệ</span>-->
                <?php echo $form->textArea($YTuong, 'GioiThieu', array('class' => 'field_value', "placeholder" => "Giới thiệu sơ việc về ý tưởng")); ?>
                <span class="field_status"><?php echo $form->error($YTuong, 'GioiThieu'); ?></span>
            </div>
            <div class="setting_field">
                <span class="field_title">Nguồn: </span>
                <?php echo $form->textField($YTuong, 'Nguon', array('class' => 'field_value')); ?>
                <span class="field_status"><?php echo $form->error($YTuong, 'Nguon'); ?></span>
            </div>
            <!--            <div class="setting_field">
                            <span class="field_title">Chia sẻ: </span>
                            <div class="field_value">
                                <input id="public_mode" type="radio" name="sharing_setting" checked="checked">
                                <label for="public_mode">Công khai</label>
                                <input id="private_mode" type="radio" name="sharing_setting">
                                <label for="private_mode">Cá nhân</label>
                            </div>
                            <span class="field_status"></span>
                        </div>-->

            <div class="setting_field">
                <span class="field_title">Ảnh bìa: </span>
                <?php echo CHtml::activeFileField($YTuong, 'AnhBia', array('class' => 'field_value')); ?>
                <span class="field_status"><?php echo $form->error($YTuong, 'AnhBia'); ?></span>
            </div>
        </div>
        <div class="setting_column2">
            <div id="field_bar" class="function_bar">
                <div class="field_collapse">
                    <a class="button_base"><span>Chọn danh mục</span></a>
                </div>

            </div>
            <div class="field_list">
                <UL id="field_tree">
                    <?php
                    foreach ($LinhVuc as $LV) {
                        echo '<LI><span>' . $LV->Ten . '</span><UL>';
                        foreach ($DanhMuc as $DM) {
                            if ($DM->LinhVucId == $LV->Id) {
                                echo '<LI class="article_field" data-id="' . $DM->Id . '"><span>' . $DM->Ten . '</span><span class="choosen_status"></span></LI>';
                            }
                        }
                        echo '</UL></LI>';
                    }
                    ?>
                </UL>
            </div>
        </div>
    </div>
    <div>
<!--        <textarea id="ArticleContent"></textarea>-->
        <?php echo $form->textArea($YTuong, 'NoiDung', array('id' => 'ArticleContent')); ?>
    </div>

    <div class="pages_bar center-child">
        <!--<a href="#" class="button_base"><span>Đăng Ý tưởng</span></a>-->
        <?php echo CHtml::submitButton('Đăng Ý tưởng', array('class' => 'button_base')); ?>
    </div>
    <?php $this->endWidget(); ?>
</div>
<script>
    $(document).ready(function() {
        CKEDITOR.replace("ArticleContent");
        $('form').submit(function() {
            var DanhMucs = [];
            $.each($('.article_field.field_choosen'), function() {
                DanhMucs.push($(this).attr('data-id'));
            });
            $('<input type="hidden" name="DanhMuc"/>').attr('value', DanhMucs).appendTo('#post-idea-form');
        });
    });
</script>